<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>文本挖掘</title>
    <link rel="icon" href="../static/img/logoIco.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="../static/css/base.css">
    <link rel="stylesheet" href="../static/css/header.css">
    <link rel="stylesheet" href="../static/css/footer.css">
    <script src="../static/js/jquery-1.12.4.js"></script>
    <link rel="stylesheet" href="../static/css/prompt.css">
    <script src="../static/js/prompt.js"></script>

    <style>
        .content{
            width: 100%;
            height: 1600px;
        }
        .content .search{
            width: 700px;
            height: 55px;
            margin: 0 auto;
            margin-top: 190px;
        }
        .search .search_left{
            width: 568px;
            height: 100%;
            float: left;
            position: relative;
        }
        .search .search_left .cancel{
            width: 55px;
            height: 55px;
            background: url("../static/img/取消.png") no-repeat center center;
            background-size: 25px 25px;
            position: absolute;
            top: 0;
            right: 0;
            opacity: 0.5;
        }
        .search #search_input{
            width: 568px;
            height: 100%;
            font-size: 16px;
            border: 1px solid #999999;
            border-top-left-radius: 30px;
            border-bottom-left-radius: 30px;
            padding: 4px 50px 4px 30px;
            border-right: 0;
            box-sizing: border-box;
            float: left;
        }
        .search #search_btn{
            width: 132px;
            height: 100%;
            color: #ffffff;
            font-size: 16px;
            border-top-right-radius: 30px;
            border-bottom-right-radius: 30px;
            border: none;
            background-color: #336EFD;
        }

        /*词云*/
        .content .wordCould{
            width: 800px;
            height: 600px;
            margin: 0 auto;
            margin-top: 100px;
            box-sizing: border-box;
        }
        .wordCould .wordCould_title{
            color: #222222;
            font-family: "Arial";
            font-size: 26px;
            line-height: 40px;
            font-weight: bold;
            text-align: center;
        }
        .line{
            width: 30px;
            height: 4px;
            background-color: #336EFD;
            margin: 0 auto;
            margin-top: 10px;
        }
        .wordCould .wordCould_img{
            width: 800px;
            height: 520px;
            padding: 20px;
            background-color: #fff;
            text-align: center;
            margin-top: 20px;
            box-shadow: 0 0 20px 0 #d8d8d8;
            box-sizing: border-box;
        }
        .wordCould .wordCould_img img{
            width: 650px;
            height: 500px;
        }

        /*主题内容*/
        .content .topic{
            width: 800px;
            height: 600px;
            margin: 0 auto;
            margin-top: 100px;
            box-sizing: border-box;
        }
        .topic .topic_title{
            color: #222222;
            font-family: "Arial";
            font-size: 26px;
            line-height: 40px;
            font-weight: bold;
            text-align: center;
        }
        .topic .topic_area{
            width: 800px;
            height: 520px;
            font-size: 18px;
            line-height: 27px;
            text-align: left;
            padding: 50px;
            background-color: #fff;
            margin-top: 20px;
            box-shadow: 0 0 20px 0 #d8d8d8;
            box-sizing: border-box;
            /*内容超出换行*/
            word-wrap:break-word;
            overflow: hidden;
        }
        .topic_area p{
            margin-top: 15px;
            margin-bottom: 15px;
        }

    </style>

    <script>
        $(function () {
            // 点击取消按钮，清空输入框
            $(".cancel").click(function () {
                $("#search_input").val("");
            });
        })
    </script>


</head>
<body>
<script>
    $(function () {

        // 注册提示
        var $timer;

        // 接收后端的数据
        var username = {{ username | safe }};

        console.log('username:'+username);

        if(username != null && username.length > 0){
            $('.nav_user').css('display','inline-block');
            $('.nav_right').css('display','none');
            $('.user_welcome').text(username);
        }

        $('.colse').click(function () {
            // $('.nav_user').css('display','none');
            // $('.nav_right').css('display','flex');
            window.location.href="http://127.0.0.1:8000/";
        })

    })
</script>

<!--接受后端词云结果-->
<script>
    $(function () {
        //var wordcloud = {{wordcloud | safe}};
        var url = {{url | safe}};
        var summary = {{summary | safe}};
        var flag = {{flag | safe}};
        var message = {{message | safe}};


        if(flag == 1){
            console.log(summary);

            var h = '<p>'+summary+'</p>';

            var text = '';
            $.each(summary, function (key, value) {
                var line = '<p>'+value+'</p>';
                text += line;
            })

            //$('#wordCould_img').attr('src', wordcloud);
            $('#search_input').val(url);
            $('.topic_area').html(text);

        }else if (flag == 0) {
           promptInfo(flag, message);
        }


    })
</script>

<script>
    $(function () {

        // 注册提示
        var $timer;

        // 接收后端的数据
        var result = {{ result | safe }};
        userstatu = result.userstatu;

        //登陆成功
        if(userstatu == 1){
            username = result.username;

            console.log('username:'+username);
            $('.nav_user').css('display','inline-block');
            $('.nav_right').css('display','none');
            $('.user_welcome').text(username);
        }


        $('.colse').click(function () {
            $('.nav_user').css('display','none');
            $('.nav_right').css('display','flex');
            window.location.href="http://127.0.0.1:8000/";
        })

    })
</script>

<!--网页头部-->
<div class="header">
    <div class="header_left">
        <a href="../index"><div class="logo"></div></a>
        <div class="header_title">一带一路 电商影响因素识别系统</div>
    </div>
    <div class="header_right">
        <ul class="nav_left">
            <a href="../textMining"><li>文本挖掘</li></a>
            <a href="../dataAnalysis"><li>大数据分析</li></a>
            <a href="../tech"><li>技术实现</li></a>
            <a href="../projectDesc"><li>项目介绍</li></a>
            <a href="../selfCenter"><li>个人简介</li></a>
        </ul>

        <!--登录注册-->
        <ul class="nav_right">
            <a href="/"><li class="login">登录</li></a>
            <a href="../register"><li class="register">注册</li></a>
        </ul>

        <!--用户登录成功-->
        <form method="post">
            {% csrf_token %}

            <ul class="nav_user">
                <li class="user_img">
                    <ul class="sub">

                        <!--<li><a href="">设置</a></li>-->
                        <li class="colse" name="close" value="1">退出</li>

                    </ul>
                </li>
                <li class="user_welcome"></li>
            </ul>
        </form>
    </div>
</div>

<div class="content">
    <form method="post">
        {% csrf_token %}
    <div class="search">
        <div class="search_left">
            <input id="search_input" type="text" placeholder="请输入网址" name="url"  >
            <i class="cancel"></i>
        </div>

        <button id="search_btn" type="submit">文本挖掘</button>
    </div>
    </form>
    <div class="wordCould">
        <div class="wordCould_title">生成词云</div>
        <div class="line"></div>
        <div class="wordCould_img">
            <img id="wordCould_img" src="{{ wordcloud }}"/>
        </div>
    </div>
    <div class="topic">
        <div class="topic_title">主题内容</div>
        <div class="line"></div>
        <div class="topic_area">
            {% for i in summary %}
            <p>{{i}}</p>
            {% endfor %}
        </div>
    </div>

</div>

<!--网页底部-->
<div class="footer">
    <div class="top">

        <span class="QRcode"><img src="../static/img/QRcode.jpg"/> </span>
        <a href="#"><div class="goback">回到顶部</div></a>

    </div>
    <div class="down">
        <div class="selfInfo">
            <a href="../selfCenter">个人简介</a>
            |
            <a href="../projectDesc">项目介绍</a>
        </div>
        <div class="copyright">
            copyright@2017-2020 陈薇
        </div>
    </div>
</div>

</body>
</html>